package com.sfy.login.factory;

import com.sfy.login.service.LoginService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
@Slf4j
public class LoginServiceFactory {
    @Resource
    List<LoginService> loginServices;

    public LoginService getLoginServiceByType(String type){
        for (LoginService loginService : loginServices) {
            if (loginService.supports(type)){
                return loginService;
            }
        }
        log.error("登陆方式异常");
        throw new RuntimeException("请选择正确的登陆方式");
    }
}
